package com.systemsjr.jrenterprise.service;

import javax.swing.JTable;
import javax.swing.table.TableColumnModel;

import com.systemsjr.jrenterprise.service.vo.ServiceVO;
import com.systemsjr.jrenterprise.utils.ServiceUtils;
import com.systemsjr.jrlib.richclient.BaseItemTable;

public class ServiceTable extends BaseItemTable<ServiceVO> {

	public ServiceTable() {
		super(new ServiceVO[]{}, "serviceTable", new String[]{
				"code",
				"serviceName",
				"price",
				"priceVAT"
		});
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void configureTable(JTable table) {
		super.configureTable(table);
		TableColumnModel tcm = table.getColumnModel();
		tcm.getColumn(0).setPreferredWidth(50);
		tcm.getColumn(1).setPreferredWidth(100);
		tcm.getColumn(2).setPreferredWidth(30);
		tcm.getColumn(3).setPreferredWidth(30);
	}
	
	@Override
	protected Object[] getDefaultInitialData() {
		setInitialData(ServiceUtils.getServiceService().loadAll().toArray());
		return getInitialData();
	}
}
